package com.winshare.saleAssistant.util;

import java.util.List;

public class Page<T>{
    private long currentPage;
    private long pageSize;
    private long totalPage;
    private long totalCount;
    private long lastPage;
    private long nextPage;
    private long endPage;
    private long indexPage;
    private List<T> data;

    public Page() {
        this.currentPage = 1L;
        this.pageSize = 10L;
        this.indexPage = 1L;
    }

    public Page(long currentPage, long pageSize, long totalCount, List<T> data) {
        this(currentPage, pageSize, totalCount);
        this.data = data;
    }

    public Page(long currentPage, long pageSize, long totalCount) {
        this.currentPage = 1L;
        this.pageSize = 10L;
        this.indexPage = 1L;
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalPage = totalCount % pageSize == 0L ? totalCount / pageSize : totalCount / pageSize + 1L;
        this.endPage = this.totalPage;
        this.totalCount = totalCount;
        this.nextPage = this.currentPage + 1L > this.endPage ? this.endPage : this.currentPage + 1L;
        this.lastPage = this.currentPage - 1L < 1L ? 1L : this.currentPage - 1L;
    }

    public Page(long currentPage, long pageSize, List<T> data) {
        this(currentPage, pageSize);
        this.data = data;
    }

    public Page(long currentPage, long pageSize) {
        this.currentPage = 1L;
        this.pageSize = 10L;
        this.indexPage = 1L;
        this.currentPage = currentPage;
        this.pageSize = pageSize;
    }

    public long getCurrentPage() {
        return this.currentPage;
    }

    public void setCurrentPage(long currentPage) {
        this.currentPage = currentPage;
    }

    public long getPageSize() {
        return this.pageSize;
    }

    public void setPageSize(long pageSize) {
        this.pageSize = pageSize;
    }

    public long getTotalPage() {
        return this.totalPage;
    }

    public void setTotalPage(long totalPage) {
        this.totalPage = totalPage;
    }

    public long getTotalCount() {
        return this.totalCount;
    }

    public void setTotalCount(long totalCount) {
        this.totalCount = totalCount;
    }

    public long getLastPage() {
        return this.lastPage;
    }

    public void setLastPage(long lastPage) {
        this.lastPage = lastPage;
    }

    public long getNextPage() {
        return this.nextPage;
    }

    public void setNextPage(long nextPage) {
        this.nextPage = nextPage;
    }

    public long getEndPage() {
        return this.endPage;
    }

    public void setEndPage(long endPage) {
        this.endPage = endPage;
    }

    public long getIndexPage() {
        return this.indexPage;
    }

    public void setIndexPage(long indexPage) {
        this.indexPage = indexPage;
    }

    public List<T> getData() {
        return this.data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }
}
